
<?php
include_once('admin-load.php');
    $query = "SELECT * FROM shipment_detail";
    $shipments = $dbna->get_results($query);
    //print_r($users)
   if (isset($_GET['action']) && $_GET['action'] == 'delete') {
       $shipment_id = $_GET['shipment_id'];
       if (isset($_GET['confirm']) && $_GET['confirm']==1) {
           delete_shipment_detail($shipment_id);
       }
       $msg = 'Do you want to delete shipment detail? <a href="shipment-detail.php?action=delete&shipment_id='.$shipment_id.'&confirm=1">YES</a> <a href="shipment-detail.php">NO</a>';
   }
?>
<?php
	include_once 'header.php';
?>
            <div id="main_content">
                <div id="content">
                    
				</div>
					<div class="container">
            <h5>shipment_detail</h5>

					</div>
				<div id="main">
                    <h2>shipment-detail</h2>
                    <?php
                        if (isset($msg)) {
                            echo '<div class="warning">'. $msg . '</div>';
                        }
                    ?>
                    <table>
                        <thead>
                            <tr>
                                <th>Origin</th>
                                <th>Weight</th>
				<th>Prices</th>
                                <th>Description</th>
                                <th>Pieces</th>
                                <th>Payment</th>
                                <th>Payment type</th>
                                <th>Edit/delete</th>
                                
                               
                            </tr>
                        </thead>
                        <tbody>
                           <?php
                                if (!empty ($shipments)) {
                                    foreach($shipments as $s) {
                                         $edit = '<a href="shipment-detail-edit.php?shipment_id='.$s->id.'"> Edit</a>';
                                         $delete = '<a href="shipment-detail.php?action=delete&shipment_id='.$s->id.'">Delete</a>';
                                        printf('<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>',
                                                $s->origin, $s->weight, $s->price, $s->decription,$s->pieces,$s->payment,$s->payment_type, $edit. ' '.$delete
                                               );
                                    }
                                }
                            ?>
                        </tbody>
                    </table>
                </div>
            </div>
<?php 
	include_once 'footer.php';
?>